package com.enqualcomm.kids.base;

import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;

import java.lang.ref.WeakReference;

/**
 * Created by yinzhiqun on 2015/9/17.
 *
 */
public class MyResultReceiver  extends ResultReceiver {

    private WeakReference<BaseActivity> weakReference;
    public MyResultReceiver(Handler handler,BaseActivity activity) {
        super(handler);
        weakReference = new WeakReference<>(activity);
    }

    @Override
    protected void onReceiveResult(int resultCode, Bundle resultData) {
        final BaseActivity activity = weakReference.get();
        if (activity!=null && !activity.isDestroyed){
            activity.onReceiveResult(resultCode,resultData);
        }
    }
}
